<? 	 ?>
<? include_once("../class/Usuario.class.php"); ?>
<? include_once("../class/Database.class.php"); ?>
<?php
/**
 * admin.login.php
 *
 * Author: JohnGR
 * Created: 03/12/2009
 * Last Modified: 14/12/2009
 * Depends on files: no
 *
 */

	$a_uname = $_POST["admin_uname"];
	$a_pass = $_POST["admin_pass"];
	$unUsuario = new Usuario();
	
	$db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); 
	$db->connect(); 
	
	$esValido = $unUsuario->loguearUsuario($db,$a_uname,$a_pass);
	
	$db->close(); 
	
	if ($esValido) {
			session_start();
			$_SESSION["admin"] = $unUsuario ;
			if ($unUsuario->esAdmin != 1)
				header("Location: ../facturasListar.php");
			else
				header("Location: ../usuarioListar.php");
	}
	else {
			header("Location: ../login.php?error=1");
	}
	
?>